<?php
require ('../include/init.inc.php');
$method = $module_id = '';
Template::assign ( 'content_header', $menu );
extract ( $_GET );

if ($start_time != date("Y-m-d",time()) && $start_time != date("Y-m-d",time()+24*60*60)) {
	$start_time = date("Y-m-d",time());
	$_GET["start_time"] = $start_time;
}

$open_time = $start_time;	

if ($method=='sure') {

	$modules = Card::getList($card_no,$open_phone,$open_time." 00:00:00",$end_time);
	$phones = Card::getPhoneList($open_time." 00:00:00");
	for ($i=0; $i < count($modules); $i++) { 
		if (count($phones)>$i) {
			Card::assignPhone($modules[$i]["id"],$phones[$i]["id"]);
		}
	}
	Common::exitWithSuccess ( '已封停','panel/sms.php' );
}

$modules = Card::getList($card_no,$open_phone,$open_time." 00:00:00",$end_time);
$phones = Card::getPhoneList($open_time." 00:00:00");
for ($i=0; $i < count($modules); $i++) { 
	if (count($phones)>$i) {
		$modules[$i]["phone"] = $phones[$i]["phone"];
	}
}
$confirm_html = OSAdmin::renderJsConfirm("icon-remove");
Template::assign ( 'modules',  $modules);
Template::assign ( '_GET', $_GET );
Template::assign ( 'open_time', $open_time );
Template::assign ( 'osadmin_action_confirm' , $confirm_html);
Template::display ( 'panel/assign_sms.tpl' );